#include <iostream>

using namespace std;

int f(int n)
{
        int tmp = 0;
        while (n)
        {
                if (n % 10 == 1)
                        tmp++;
                n /= 10;
        }
        return tmp;
}

int main()
{
        int n;
        cin >> n;
        int count = 0;
        for (int i = 1; i <= n; i++)
        {
                count += f(i);
        }
        cout << count << endl;
        return 0;
}